package com.niodata.dp.core.usermgr;

import com.niodata.dp.core.Constants;
import com.niodata.dp.core.DpConfiguration;

/**
 * hdfs username,group name util. dp username to hdfs username mapping. dp groupname to hdfs
 * username mapping. group owner hdfsuser,reader hdfsuser.
 */
public class HdfsUtil {

  /**
   * dp中用户对应的hdfs用户.
   *
   * @param userName loginname
   * @return hdfsuser
   */
  public static String getHdfsUserName(String userName) {
    return Constants.HDFS_USER_PREFIX + userName;
  }

  /**
   * get hdfs group name.
   *
   * @param groupName group name
   * @return hdfs group name
   */
  public static String getHdfsGroupName(String groupName) {
    return Constants.LDAP_GROUP_PREFIX + groupName;
  }

  /**
   * dp 组对应的hdfs owner用户.
   */
  public static String getHdfsGroupOwnerUser(String groupName) {
    return Constants.HDFS_GROUP_OWNER_USER_PREFIX + groupName;
  }

  public static String getHdfsGroupReadUser(String groupName) {
    return Constants.HDFS_READ_USER_PREFIX + groupName;
  }

  public static String getUserHdfsHome(String username) {
    return DpConfiguration.getDpHdfsUsersRootDir() + "/" + username;
  }

  public static String getGroupHdfsHome(String groupName) {
    return DpConfiguration.getDpHdfsGroupsRootDir() + "/" + groupName;
  }

}
